/* eslint valid-jsdoc: "off" */

'use strict';

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1615647835557_243';

  // add your middleware config here
  config.middleware = [];

  // add your user config here
  const userConfig = {
    // 取消csrf认证
    security: {
      csrf: {
        enable: false,
      },
    },
    // 跨域设置
    cors: {
      origin: 'http://localhost:3000',
      allowHeaders: 'token,content-type,x-requested-with, authorization',
      'credentials': 'true',
      allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH'
    },
    // mysql配置
    mysql: {
      client: {
        host: '127.0.0.1',
        port: 3306,
        user: 'root', // 必须要有用户名
        database: 'react-blogs',
        // 挂载到app
        app: true,
      }
    }
  };

  return {
    ...config,
    ...userConfig,
  };
};
